import 'dart:async';

import 'package:flutter/cupertino.dart';

import 'counter1.dart';

class Counter2 with ChangeNotifier {
  int value2 = 0;
  Timer _timer;
  CounterInt counter1;

  Counter2();

  Counter2.count1(CounterInt counter1);

  void increment2() {
    _timer = Timer.periodic(Duration(seconds: 1), (t) {
      value2 += 1;
      notifyListeners();
    });
  }

  void cancel() {
    _timer?.cancel();
    counter1.cancel();
  }
}